package demo2;

public class Test3 {
    public static void main(String[] args) {

    }
    public int pivotIndex(int[] nums) {
        int[] pd = new int[nums.length+1] ;
        for(int i=0 ; i < nums.length ; i ++){
            pd[i+1] = pd[i] + nums[i] ;
        }
        for(int i = 1 ; i < pd.length  ; i ++){
            if(pd[i-1] == pd[pd.length-1]-pd[i]){
                return i-1 ;
            }
        }
        return -1 ;

    }
}
